package offer;

public class _11_旋转数组的最小数字 {
    public static void main(String[] args) {
        int[] numbers = {3,1,3};
//        int[] numbers = {1,3,5};
        Solution solution = new _11_旋转数组的最小数字().new Solution();
        System.out.println(solution.minArray(numbers));
    }

    class Solution {
        public int minArray(int[] numbers) {
            int l = 0;
            int r = numbers.length - 1;
            while(l <= r) {
                int mid = l + (r - l) / 2;
                if (numbers[mid] < numbers[r]) {
                    r = mid;
                } else if (numbers[mid] > numbers[r]) {
                    l = mid + 1;
                } else {
                    r--;
                }
            }
            return numbers[l];
        }
    }
}
